rm(list = ls())

## packages 

library(tidyverse)
library(fixest)

## Estimate main specification with weights 

dat <- readRDS('data/civey_clean.rds') %>%
  filter(!is.na(weight)) %>%
  filter(foreign_non_eu_share_bin == 'High')

## Column 1

feols(vote_afd ~ treated_post | user_id + date, 
            data = dat,
            cluster = ~ user_id,
            weights = dat$weight) %>%
  etable()

## Column 2

feols(vote_afd ~ treated_post_placebo | user_id + date, 
            data = dat %>% filter(freibad_in_zip == 0),
            cluster = ~ user_id,
            weights = dat$weight[dat$freibad_in_zip == 0])  %>%
  etable()

